class Solution {
public:
    bool CheckPermutation(string s1, string s2) {
        unordered_map<char, int> mp1;
        unordered_map<char, int> mp2;
        int n = s1.size(), m = s2.size();
        if(n != m)  return false;
        for(int i = 0; i < n; ++i)
        {
            if(mp1.find(s1[i]) != mp1.end())
                mp1[s1[i]]++;
            else
                mp1.insert(make_pair(s1[i], 1));

            if(mp2.find(s2[i]) != mp2.end())
                mp2[s2[i]]++;                
            else
                mp2.insert(make_pair(s2[i], 1));
        }

        for(int j = 0; j < m; ++j)
        {
            if(mp1.find(s2[j]) == mp1.end() || mp2[s2[j]] != mp1[s2[j]])
                return false;
        }
        
        return true;
    }
};
